'use strict';

angular.module('SystemManage').controller('MenuListController', ['$scope', 'PublicModule', 'PublicEnum', '$location', 'Authentication',
    function($scope, PublicModule, PublicEnum, $location, Authentication) {
    	PublicModule.initModule($scope, 'Menu');
        $scope.Module.Menu.LoadMode = PublicEnum.LoadMode.CacheAndPaging;
        $scope.Module.Menu.QueryParameter.Populate = {path: 'Parent', select: 'Name'};
        $scope.Module.Menu.PageSize = 10;
        $scope.Module.Menu.load();

        $scope.btnAdd = function(){
        	$location.url('/index/Menu/Edit');
        };

        $scope.rowDblClick = function(){
            $scope.$apply(function(){
                $location.url("/index/Menu/Edit/" + $scope.Module.Menu.FocusedRecord._id);
            });
        };

        $scope.btnDelete = function(){
        	$scope.Module.Menu.deleteSelecteds(function(){
        		$scope.Module.Menu.load();
        	});
        };
    }
]);
